home *** CD-ROM | disk | FTP | other *** search
/ Software Vault: The Gold Collection / Software Vault - The Gold Collection (American Databankers) (1993).ISO / cdr25 / me310.zip / UE310C.ZIP / VT52.C < prev    next >
C/C++ Source or Header  |  1988-10-02  |  4KB  |  188 lines

  1. /*
  2.  * The routines in this file
  3.  * provide support for VT52 style terminals
  4.  * over a serial line. The serial I/O services are
  5.  * provided by routines in "termio.c". It compiles
  6.  * into nothing if not a VT52 style device. The
  7.  * bell on the VT52 is terrible, so the "beep"
  8.  * routine is conditionalized on defining BEL.
  9.  */
  10. #define    termdef    1            /* don't define "term" external */
  11.  
  12. #include        <stdio.h>
  13. #include        "estruct.h"
  14. #include    "etype.h"
  15. #include    "edef.h"
  16. #include    "elang.h"
  17.  
  18. #if     VT52
  19.  
  20. #define NROW    24                      /* Screen size.                 */
  21. #define NCOL    80                      /* Edit if you want to.         */
  22. #define    MARGIN    8            /* size of minimim margin and    */
  23. #define    SCRSIZ    64            /* scroll size for extended lines */
  24. #define    NPAUSE    100            /* # times thru update to pause */
  25. #define BIAS    0x20                    /* Origin 0 coordinate bias.    */
  26. #define ESC     0x1B                    /* ESC character.               */
  27. #define BEL     0x07                    /* ascii bell character         */
  28.  
  29. extern  int     ttopen();               /* Forward references.          */
  30. extern  int     ttgetc();
  31. extern  int     ttputc();
  32. extern  int     ttflush();
  33. extern  int     ttclose();
  34. extern  int     vt52move();
  35. extern  int     vt52eeol();
  36. extern  int     vt52eeop();
  37. extern  int     vt52beep();
  38. extern  int     vt52open();
  39. extern    int    vt52rev();
  40. extern    int    vt52cres();
  41. extern    int    vt52kopen();
  42. extern    int    vt52kclose();
  43.  
  44. #if    COLOR
  45. extern    int    vt52fcol();
  46. extern    int    vt52bcol();
  47. #endif
  48.  
  49. /*
  50.  * Dispatch table. All the
  51.  * hard fields just point into the
  52.  * terminal I/O code.
  53.  */
  54. TERM    term    = {
  55.     NROW-1,
  56.         NROW-1,
  57.         NCOL,
  58.         NCOL,
  59.     MARGIN,
  60.     SCRSIZ,
  61.     NPAUSE,
  62.         &vt52open,
  63.         &ttclose,
  64.     &vt52kopen,
  65.     &vt52kclose,
  66.         &ttgetc,
  67.         &ttputc,
  68.         &ttflush,
  69.         &vt52move,
  70.         &vt52eeol,
  71.         &vt52eeop,
  72.         &vt52beep,
  73.         &vt52rev,
  74.         &vt52cres
  75. #if    COLOR
  76.     , &vt52fcol,
  77.     &vt52bcol
  78. #endif
  79. };
  80.  
  81. vt52move(row, col)
  82. {
  83.         ttputc(ESC);
  84.         ttputc('Y');
  85.         ttputc(row+BIAS);
  86.         ttputc(col+BIAS);
  87. }
  88.  
  89. vt52eeol()
  90. {
  91.         ttputc(ESC);
  92.         ttputc('K');
  93. }
  94.  
  95. vt52eeop()
  96. {
  97.         ttputc(ESC);
  98.         ttputc('J');
  99. }
  100.  
  101. vt52rev(status)    /* set the reverse video state */
  102.  
  103. int status;    /* TRUE = reverse video, FALSE = normal video */
  104.  
  105. {
  106.     /* can't do this here, so we won't */
  107. }
  108.  
  109. vt52cres()    /* change screen resolution - (not here though) */
  110.  
  111. {
  112.     return(TRUE);
  113. }
  114.  
  115. spal()        /* change palette string */
  116.  
  117. {
  118.     /*    Does nothing here    */
  119. }
  120.  
  121. #if    COLOR
  122. vt52fcol()    /* set the forground color [NOT IMPLIMENTED] */
  123. {
  124. }
  125.  
  126. vt52bcol()    /* set the background color [NOT IMPLIMENTED] */
  127. {
  128. }
  129. #endif
  130.  
  131. vt52beep()
  132. {
  133. #ifdef  BEL
  134.         ttputc(BEL);
  135.         ttflush();
  136. #endif
  137. }
  138.  
  139. vt52open()
  140. {
  141. #if     V7 | BSD
  142.         register char *cp;
  143.         char *getenv();
  144.  
  145.         if ((cp = getenv("TERM")) == NULL) {
  146.                 puts(TEXT4);
  147. /*                   "Shell variable TERM not defined!" */
  148.                 meexit(1);
  149.         }
  150.         if (strcmp(cp, "vt52") != 0 && strcmp(cp, "z19") != 0) {
  151.                 puts(TEXT202);
  152. /*                   "Terminal type not 'vt52'or 'z19' !" */
  153.                 meexit(1);
  154.         }
  155. #endif
  156.         ttopen();
  157. }
  158.  
  159. vt52kopen()
  160.  
  161. {
  162. }
  163.  
  164. vt52kclose()
  165.  
  166. {
  167. }
  168.  
  169.  
  170. #if    FLABEL
  171. fnclabel(f, n)        /* label a function key */
  172.  
  173. int f,n;    /* default flag, numeric argument [unused] */
  174.  
  175. {
  176.     /* on machines with no function keys...don't bother */
  177.     return(TRUE);
  178. }
  179. #endif
  180. #else
  181.  
  182. vt52hello()
  183.  
  184. {
  185. }
  186.  
  187. #endif
  188.